// 定义食物
export default class Food {
    element: HTMLElement
    
    constructor() {
        this.element = document.getElementById('food')!
    }

    // 获取 X 轴坐标
    get X() {
        return this.element.offsetLeft
    }

    // 获取 Y 轴坐标
    get Y() {
        return this.element.offsetTop
    }

    // 设置 X/Y 轴坐标
    XY() {
        const leftPX = Math.round(Math.random() * 38) * 10
        const topPx = Math.round(Math.random() * 34) * 10
        this.element.style.left = leftPX + 'px'
        this.element.style.top = topPx + 'px'
    }
}